﻿using System.Collections.Generic;
using MagicKey.Components.UserManager;

namespace MagicKey.Interfaces
{
    public interface IDatabase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        string LoadAllEntries();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="salt"></param>
        /// <param name="puKey"></param>
        /// <param name="prKey"></param>
        /// <param name="idUserRole"></param>
        /// <returns></returns>
        bool InsertUser(string username, string password, string salt, string puKey, string prKey, int idUserRole);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        int InsertFile(string path, int userId);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="recipient"></param>
        /// <param name="file"></param>
        /// <param name="encryptedSymetricKeyOfRecipient"></param>
        /// <param name="encryptedSymetricKeyOfSender"></param>
        /// <returns></returns>
        bool InsertAuthorization(int sender, int recipient, int file, string encryptedSymetricKeyOfRecipient,
            string encryptedSymetricKeyOfSender);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        bool RemoveAuthorization(int userId);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        bool DeleteFile(string path, int userId);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        string LoadParameterUser(string type, string username);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        List<User> LoadAllUsers();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        string GetUserId(string username, string password);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        int GetFileId(string path);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        bool HasAuthorization(int userId, string path);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        string GetOwnerName(string path);

        /// <summary>
        /// Select a symetric key of user file
        /// </summary>
        /// <param name="path">path of file</param>
        /// <param name="userId">user id</param>
        /// <param name="isOwner">true if userId is owner of a file with a fullname path</param>
        /// <returns></returns>
        string LoadSymetricKeyOfFile(string path, int userId, bool isOwner);
    }
}